// Learn cc.Class:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
/**
 * 我的团队
 */
let base = require("panelBase")
let viewConfig = {
    btn_back:{
        node:null,
        name:"btn_back",
        eventType:"click",
        cb:"onBtnBackClick",
    },
    btn_info:{
        node:null,
        name:"curTarget/btn_info",
        eventType:"click",
        cb:"onBtnInfoClick"
    },
    // 邀请好友
    btn_invite:{
        node:null,
        name:"btn_invite_friend",
        eventType:"click",
        cb:"onBtnInviteClick"
    },
    //二维码
    btn_qr:{
        node:null,
        name:"btn_qr_code",
        eventType:"click",
        cb:"onBtnQrClick"
    },
    invite_num:{
        node:null,
        name:"curTarget/content",

    },
    invite_pb:{
        node:null,
        name:"curTarget/pb"
    },
    tips:{
        node:null,
        name:"tipsBg/con"
    },
    btn_tdmx_top:{
        node:null,
        name:"group_gain/btn_info_top",
        eventType:"click",
        cb:'onBtnTdmxTopClick'
    },
    btn_tdmx_buttom:{
        node:null,
        name:"group_gain/btn_info_buttom",
        eventType:"click",
        cb:"onBtnTdmxButtomClick"
    },
    // 总收徒
    zst:{
        node:null,
        name:"group_gain/zst/num"
    },
     // 徒弟人数
     tdrs:{
        node:null,
        name:"group_gain/td/num"
    },
     // 徒孙人数
     tsrs:{
        node:null,
        name:"group_gain/ts/num"
    },
     // 总收益
     zsy:{
        node:null,
        name:"group_gain/zsy/num"
    },
     // 徒弟贡献
    tdgx:{
        node:null,
        name:"group_gain/zst/num"
    },
     // 徒孙贡献
     tsgx:{
        node:null,
        name:"group_gain/zst/num"
    }, 
    // 二维码界面
    invitePanel:{
        node:null,
        name:"in_qr_panel",
        active:false,
    },

    in_btn_close:{
        node:null,
        name:"in_qr_panel/btn_close",
        eventType:"click",
        cb:"onBtnInClose"
    },

    in_btn_share:{
        node:null,
        name:"in_qr_panel/btn_share",
        eventType:"click",
        cb:"onBtnInShareClick"
    },
    head:{
        node:null,
        name:"in_qr_panel/con_bg/head",
    },
    nickName:{
        node:null,
        name:"in_qr_panel/con_bg/nickName"
    },
    invite_code:{
        node:null,
        name:"in_qr_panel/con_bg/yqm"
    },
    // 二维码
    qr_code:{
        node:null,
        name:"in_qr_panel/con_bg/qr_code"
    }
}
cc.Class({
    extends: base,

    properties: {
       
    },

    init(){
        this._super(viewConfig);
        this.isInited = true;
        this.onHide();
    },

    onShow(){
        this._super();
        if(cc.tg.cakeRoom.invicationCode != null)
        {
            this.updateInfo(viewConfig["invite_code"].node,cc.tg.cakeRoom.invicationCode,cc.Label);
            cc.tg.adDataCenter.createQR(viewConfig["qr_code"].node,"www.baidu.com");
        }
    },
    onBtnBackClick(){
        this.onHide();
    },
    onBtnInfoClick(){
        cc.log("on btn info click ");
    },

    onBtnInviteClick(){
       
        cc.tg.eventCenter.dispatchEvent("showPanel",{panelName:"fh",active:true})
        cc.tg.eventCenter.dispatchEvent("onShowInvite");
        this.onHide();
    },

    onBtnQrClick(){
        viewConfig["invitePanel"].node.active = true;
    },

    onBtnTdmxTopClick(){
        
    },
    onBtnTdmxButtomClick(){

    },

    onBtnInClose(){
        viewConfig["invitePanel"].node.active = false;
    },
    onBtnInShareClick(){

    },

    onDestroy(){
        for(let key in viewConfig)
        {
            viewConfig[key].node = null;
        }
    },
});
